<?php

include 'seguranca.php';
include 'Model/DAO/ConnectionPDO.php';
include 'Model/DAO/FiliacaoDAO.php';
include 'Model/Filiacao.php';
protegePagina();

$filiacaoDAO = new FiliacaoDAO();

if(isset($_POST['edtFiliacao']))
{
  $filiacao = new Filiacao();
  $filiacao->setIdFiliacao($_GET['IDFiliacao']);
  $filiacao->setNomeMae($_POST['mae']);
  $filiacao->setNomePai($_POST['pai']);

  $filiacaoDAO->updateFiliacao($filiacao);

  if($filiacaoDAO) {
    $msg = 'Registro alterado com sucesso';
    header('Location: filiacao_list.php');
  } else  {
   $msg = 'Não foi possivel alterar o registro,tente novamente';
   header('Location: filiacao_edit.php');
  }
}
$showFiliacao = $filiacaoDAO->getByIDFiliacao($_GET['IDFiliacao']);
?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='pt-br' lang='pt-br'>
    <head>
        <meta http-equiv='content-type' content='text/html; charset=utf-8' />
        <meta http-equiv='content-language' content='pt-br' />
        <meta name='robots' content='noindex,nofollow' />
        <link rel='stylesheet' media='screen,projection' type='text/css' href='css/reset.css' /> <!-- RESET -->
        <link rel='stylesheet' media='screen,projection' type='text/css' href='css/main.css' /> <!-- MAIN STYLE SHEET -->
        <link rel='stylesheet' media='screen,projection' type='text/css' href='css/2col.css' title='2col' /> <!-- DEFAULT: 2 COLUMNS -->
        <link rel='alternate stylesheet' media='screen,projection' type='text/css' href='css/1col.css' title='1col' /> <!-- ALTERNATE: 1 COLUMN -->
        <!--[if lte IE 6]><link rel='stylesheet' media='screen,projection' type='text/css' href='css/main-ie6.css' /><![endif]--> <!-- MSIE6 -->
        <link rel='stylesheet' media='screen,projection' type='text/css' href='css/style.css' /> <!-- GRAPHIC THEME -->
        <link rel='stylesheet' media='screen,projection' type='text/css' href='css/mystyle.css' /> <!-- WRITE YOUR CSS CODE HERE -->
        <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
        <script type='text/javascript' src='js/jquery.switcher.js'></script>
        <script type='text/javascript' src='js/maskedinput.js'></script>
        <script type='text/javascript' src='js/jquery.validate.min.js'></script>
        <script type='text/javascript' src='js/toggle.js'></script>
        <script type='text/javascript'>
            $(document).ready(function(){
                $('#nasc').mask('99/99/9999');
                $('#frmTouro').validate({
                  errorLabelContainer: '.msg error',
                    wrapper: 'li',
                    errorClass: 'error',

                    rules:{

                    },
                    messages:{

                    }
                })
            });
        </script>
        <title>Touros</title>
    </head>
    <body>
        <div id='main'>
            <?php include 'includes/inc_header.php' ?>
            <?php include 'includes/inc_menu.php' ?>
            <div id='cols' class='box'><?php include 'includes/left-colum-cad.php' ?></div>

            <!-- Content (Right Column) -->
            <div id='content' class='box'>
                <h1>Alterar filiação</h1>

                <p class='msg info' id="error"></p>
                <div class='msg error' id="error"></div>
                <form action='' method='post' id='frmFili'>
                    <fieldset>
                        <legend>Filiação</legend>
                        <p class='nomt'>
                            <label for='nome' class='req'>Touro: *</label><br />
                            <input type='text'
                                   size='60'
                                   name='pai'
                                   class='input-text required'
                                   id='nome'
                                   value='<?=$showFiliacao->getNomePai()?>'
                                   title="Preencha o nome do animal"  />
                        </p>

                        <p class='nomt'>
                            <label for='nome' class='req'>Matriz: *</label><br />
                            <input type='text'
                                   size='60'
                                   name='mae'
                                   class='input-text required'
                                   id='nome'
                                   value='<?=$showFiliacao->getNomeMae()?>'/>
                        </p>
                    </fieldset>
                     <p><input type='submit' name="edtFiliacao" value='Editar' /></p>
                </form>
            </div>
        </div>
        <hr class='noscreen' />
<?php include 'includes/inc_footer.php' ?>
